using System;
using UnityEngine;

public class FindExitBehaviour : SteeringBehaviour
{
	public FindExitBehaviour ()
	{
	
	}
	

	public override Vector3 getSteering (AgentBehaviourScript agent)
	{	
		
		// on error return the agent destination
		try
		{
			return ((GameController)GameObject. FindWithTag("GameController").GetComponent("GameController")).getNearestExit(agent.getPosition());
		}
		catch
		{
			return agent.getDestination();
		}
	}
	
}
